from django.db import models
from django.utils import timezone

class Product(models.Model):
    PRODUCTS_CHOICES = (('1', '西甲联赛'), ('2', '英超联赛'), ('3', '意甲联赛'),('4', '德甲联赛'),('5','法甲联赛'))
    id = models.AutoField('编号', primary_key=True)
    productType = models.CharField('联赛类别', choices=PRODUCTS_CHOICES, max_length=50)
    title = models.CharField('标题', max_length=50)
    desc = models.TextField('介绍')
    price = models.DecimalField('球队身价（亿欧元）', decimal_places=2, max_digits=7)
    pubDate = models.DateTimeField('发布日期', default=timezone.now)


    def __str__(self):
        return self.title

    class Meta:
        verbose_name = '球队'
        verbose_name_plural = '球队'



class ProductImg(models.Model):
    product = models.ForeignKey(Product, related_name='productImgs', verbose_name='球队', on_delete=models.CASCADE)
    photo = models.ImageField(upload_to='product/', blank=True, verbose_name='球队图片')

    class Meta:
        verbose_name = '球队图片'
        verbose_name_plural = '球队图片'